package think.thread.sychron.c01;

import java.util.concurrent.TimeUnit;

public class WaxOnCarThread {
	public static void main(String[] args) throws Exception {
		Car car = new Car();

		Thread offThread = new Thread(new WaxOff(car));
		Thread onThread = new Thread(new WaxOn(car));

		offThread.start();
		onThread.start();

		TimeUnit.SECONDS.sleep(3);
		
		System.out.println(offThread.getState().name());
		System.out.println(onThread.getState().name());
		
		offThread.interrupt();
		onThread.interrupt();
	}

	// public static void main(String[] args) throws Exception {
	// WaitClass class1=new WaxOnCarThread().new WaitClass();
	//
	// class1.start();
	// TimeUnit.SECONDS.sleep(3);
	//
	// class1.interrupt();
	//
	// }

	class WaitClass extends Thread {

		public void waitTime() throws Exception {
			while (true)
				wait();
		}

	}

}
